package com.zy.teacherSide.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zy.teacherSide.dao.CourseDao;
import com.zy.teacherSide.entity.Course;
import com.zy.teacherSide.service.ICourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 29787
 */
@Service
public class ICourseServiceImpl extends ServiceImpl<CourseDao, Course> implements ICourseService {

    @Autowired
    private CourseDao courseDao;

    @Override
    public Course getCourse(String courseName, Integer teacherId, Integer classroomId) {
        return courseDao.getCourse(courseName, teacherId, classroomId);
    }

    @Override
    public IPage<Course> getPage(Integer currentPage, Integer pageSize, Integer teacherId) {
        IPage<Course> page = new Page<>(currentPage, pageSize);
        LambdaQueryWrapper<Course> lqw = new LambdaQueryWrapper<>();
        lqw.eq(true,Course::getTeacherId,teacherId);
        courseDao.selectPage(page,lqw);
        return page;
    }

    @Override
    public Course getCourseByCourseNameAndTeacherId(String courseName, Integer teacherId) {
        return courseDao.getCourseByCourseNameAndTeacherId(courseName, teacherId);
    }

    @Override
    public List<Course> getAllCourse(Integer teacherId) {
        return courseDao.getAllCourse(teacherId);
    }

    @Override
    public Course getAllCourseByCourseId(Integer teacherId, Integer courseId) {
        return courseDao.getAllCourseByCourseId(teacherId, courseId);
    }

    @Override
    public List<Course> getCourseByClassroomIdAndTeacherId(Integer teacherId, Integer classroomId) {
        return courseDao.getCourseByClassroomIdAndTeacherId(teacherId, classroomId);
    }

    @Override
    public List<Course>  getAllCourseByTeacherIdAndClassroomId(Integer teacherId,Integer classroomId) {
        return courseDao.getAllCourseByTeacherIdAndClassroomId(teacherId, classroomId);
    }
}
